<template>
  <div class='news-list'>
    <van-card
      v-for="item in newslist"
      :key="item.id"
      :title="item.title"
      :thumb="item.img_url"
      @click.prevent="godetail(item.id)"
    >
      <!-- Uncaught TypeError: Cannot read property 'match' of null
    at U (<anonymous>:1:244)
    at er (<anonymous>:1:303) -->
      <template #price>
        {{item.add_time}}
      </template>
      <template #num>
        点击{{item.click}}次
      </template>
    </van-card>

  </div>
</template>
<script>

export default {
  data: () => ({
    newslist: []
  }),
  created() {
    this.getnewslist();
  },
  methods: {
    async getnewslist() {
      const res = await this.$http.getnewslist();
      // console.log(res);
      this.newslist = res.data.message;
    },
    godetail(id) {
      this.$router.push('/home/newsInfo/' + id);
    }

  }
}
</script>
<style lang="scss" scoped>
.news-list {
  .van-card__thumb {
    height: 55px;
  }
  .van-card__content {
    min-height: 55px;
    .van-card__title {
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 1;
      overflow: hidden;
    }
    .van-card__price {
      color: red;
    }
  }
}
</style>